# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-cairo2
_pkgname=cairo2
pkgver=0.6.2
pkgrel=1
pkgdesc="OCaml bindings to Cairo, a 2D Vector Graphics Library"
url="https://github.com/Chris00/ocaml-cairo"
arch="all !riscv64" # restricted by ocaml
license="LGPL-3.0-only"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="
	dune
	dune-configurator-dev
	ocaml
	ocaml-compiler-libs
	ocaml-csexp-dev
	cairo-dev
	"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/Chris00/ocaml-cairo/releases/download/$pkgver/cairo2-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build -p cairo2 @install --no-buffer --verbose
}

check() {
	dune runtest --no-buffer --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml \
		cairo2

	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
789b65428855c3b8fb71836ee6e607870c3140a6152fb01b8ba6e7d2e2f4842a62412061a5eff99023234d305587b605d0cbbacd29456c86a52e9df6466bd302  ocaml-cairo2-0.6.2.tar.bz2
"
